typedef float real;

#include <vector>
//#define GLM_FORCE_SSE2 
//#define GLM_FORCE_INLINE 
#include <glm\glm.hpp>


class FluidSolver
{
	static const int MAX_PARTICLES = 1024*4;
	static const int MAX_NEIGHBORS = 128;

	struct neighbor 
	{ 
		unsigned int i, j; 
		real q, q2, lng; 
	};

	// The particle structure holding all of the relevant information.
	struct particle 
	{ 
		glm::vec2 pos;
		glm::vec2 pos_old;
		glm::vec2 vel;
		glm::vec2 force; 
		real mass, rho, rho_near, press, press_near, sigma, beta; 
		std::vector<neighbor> neighbors;  
	};

private:
	int N;                     // Number of Particles in the simulation
	real G, spacing, k, k_near, rest_density, sigma, beta, r, rsq, SIM_W, bottom;
	// Our collection of particles
	int particlesCreated;

	// Mouse attractor
	glm::vec2 attractor;
	

	particle particles[MAX_PARTICLES];
	std::vector< glm::vec2 > verts;

private:
	unsigned int VertexVBOID;
	
	void generateColorLUT();
public:
	void initParticles();
	double uploadTime;
	int attracting, repelling;
	FluidSolver();
	~FluidSolver();
	void render();
	void update();
	void activateAttractor( int x, int y );
	void deactivateAttractor();
	void addParticles( int x, int y );
	int getParticleCount() { return particlesCreated; }
	void activateRepelling( int mx, int my );
	void removeAllParticles() { particlesCreated = 0; }
};